package com.giscloud.generator.controller;

import com.giscloud.generator.entity.vo.UserIdentityVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ViewController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(ViewController.class);

    @RequestMapping(value = {"/","/index","/home"}, method = RequestMethod.GET)
    ModelAndView index() {
        ModelAndView view = new ModelAndView();
        view.setViewName("index");
        loadLoginInfo(view);
        return view;
    }

    private void loadLoginInfo(ModelAndView view) {
        UserIdentityVO userIdentityVO = getLoginUser();
        if(userIdentityVO == null ){
            view.addObject("isShowLogin", "1");
        }else{
            view.addObject("staffName", userIdentityVO.getRealName());
            view.addObject("isShowConsole", "1");
            view.addObject("isUserInfo", "1");
        }
    }

}
